<?php 
$this->addTitle("Buglist");
echo "<h3>Buglist</h3><br />";
echo "\n";
$debug=false;

global $conf;
if($conf['bug']){
	#$content = file_get_contents($conf['bug_url']);
	
	#echo $content;
	#echo $conf['bug_url'];
	$xml = simplexml_load_file($conf['bug_url']);
	#$xml = simplexml_load_string($content);
	
	if(isset($_POST['bug_send'])){
		$string ="bug_title={$_POST['bug_title']}\n";
		$string.="bug_version=".$this->version."\n";
		$string.="bug_found=".time()."\n";
		$string.="bug_autor={$_POST['bug_autor']}\n";
		$string.="autor_mail={$_POST['autor_mail']}\n";
		$string.="bug_text=".preg_replace("!\n|\r!", "<br />", $_POST['bug_text'])."\n";
		$string.="bug_solution=".preg_replace("!\n|\r!", "<br />", $_POST['bug_solution'])."\n";
		
		mail($conf['bug_sendto'],"AllianzTool-Bug",$string);
		
		echo "<span style=\"color:green\"><strong>BUG gesendet</strong></span><br /><br />";
	}
	
	
	echo "<a id=\"add_0\" style=\"font-size:90%;\" onclick=\"hide('add_0');hide('add_1');\"><img src=\"images/icon_add.png\" alt=\"add\" /> {$lang['base']['bug_new']}<br /><br /></a>";
	
	echo "<form id=\"add_1\" name=\"add_1\" method=\"post\" action=\"\" style=\"display:none\">
	<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\" style=\"background-image:url(images/list_gray.png); filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/list_gray.png', sizingMethod='scale');\">
		  <tr>
			<td width=\"100\">{$lang['base']['bug_title']}:</td>
			<td width=\"160\"><input type=\"text\" name=\"bug_name\" /></td>
			<td width=\"20\"></td>
			<td width=\"100\">{$lang['base']['bug_version']}:</td>
			<td width=\"160\"><input type=\"text\" name=\"tool_version\" value=\"".$this->version."\" readonly/></td>
			<td></td>
		  </tr>
		  <tr>
			<td>{$lang['base']['bug_autor']}:</td>
			<td width=\"160\"><input type=\"text\" name=\"bug_autor\" value=\"".$this->user_name."\" /></td>
			<td></td>
			<td>{$lang['base']['mail']}:</td>
			<td><input type=\"text\" name=\"autor_mail\" value=\"".$this->user_mail."\"/></td>
			<td>&nbsp;</td>
		  </tr>
		  <tr>
			<td>&nbsp;</td>
			<td colspan=\"5\">&nbsp;</td>
			</tr>
		  <tr>
			<td valign=\"top\">{$lang['base']['bug_text']}:</td>
			<td colspan=\"5\"><textarea name=\"bug_text\" style=\"width:100%; height:70px;\"></textarea></td>
		  </tr>
		  <tr>
			<td valign=\"top\">{$lang['base']['bug_solution']}: </td>
			<td colspan=\"5\"><textarea name=\"bug_solution\" style=\"width:100%; height:70px;\"></textarea></td>
		  </tr>
		  <tr>
			<td>&nbsp;</td>
			<td colspan=\"5\">&nbsp;</td>
		  </tr>
		  <tr>
			<td>&nbsp;</td>
			<td colspan=\"5\"><input type=\"bug_send\" name=\"bug_send\" value=\"Eintragen\" /></td>
		  </tr>
	</table>
	</form>	";
	
	
	
	if($debug){
		echo "<pre>";
		print_r($xml);
		echo "</pre>";
	}
	
	
	if(isset($xml->fid)){
		echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\" width=\"100%\">\n\t<tr>\n\t";
		echo "<th width=\"30\">#</th>\n\t";
		echo "<th><a href=\"\">{$lang['base']['bug_title']}</a> <span style=\"font-size:80%;\">(<a href=\"\">{$lang['base']['bug_autor']}</a>)</span></th>\n\t";
		echo "<th><a href=\"\">{$lang['base']['bug_found']}</a></th>\n\t";
		echo "<th><a href=\"\">{$lang['base']['bug_solved']}</a></th>\n\t";
		echo "<th><a href=\"\">{$lang['base']['bug_version']}</a></th>\n\t";
		echo "<th width=\"100\">&nbsp;</th>\n\t";
		echo "</tr>\n";
		$c=1;
		foreach($xml->fid as $line){
			$c++;
			echo "<tr style=\"";
			if($c%2)
				echo " background-image:url(images/list_gray.png); filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/list_gray.png', sizingMethod='scale');";
			echo "\">";
			
			echo "<td align=\"center\">".($c-1)."</td>";
			echo "<td><strong>".urldecode($line->name)."</strong> <span style=\"font-size:80%;\">von ".urldecode($line->autor)."</span></td>";
			echo "<td align=\"center\">".date("Y-M-d H:i", (int) $line->date_in)."</td>";
			echo "<td align=\"center\">";
				if((int) $line->date_out < 1000)
					echo "<span style=\"color:red;\">NO</span>";
				else
					echo date("Y-M-d H:i", (int) $line->date_out);
			echo "</td>";
			echo "<td align=\"center\">".$line->aToolV."</td>";
			echo "<td>";
				echo "<img id=\"id_{$c}_0\" src=\"images/icon_big.png\" onclick=\"hide('id_{$c}');hide('id_{$c}_0');hide('id_{$c}_1');\" width=\"16\" height=\"16\" /><img id=\"id_{$c}_1\" onclick=\"hide('id_{$c}');hide('id_{$c}_0');hide('id_{$c}_1');\" src=\"images/icon_small.png\" width=\"16\" height=\"16\" style=\"display:none;\" />	";			

			echo "</td>";
			echo "</tr>";			
			
			echo "<tr id=\"id_$c\" style=\"display:none;";
			if($c%2)
				echo " background-image:url(images/list_gray.png); filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/list_gray.png', sizingMethod='scale');";
			echo "\">";
			echo "<td align=\"center\">&nbsp;</td>";
			echo "<td colspan=\"5\">";
				echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\" width=\"100%\">";
					echo "<tr>";
						echo "<td valign=\"top\" width=\"150\">".$lang['base']['bug_text']."</td>";
						echo "<td>".urldecode($line->beschreibung)."</td>";
					echo "</tr>";
					echo "<tr>";
						echo "<td valign=\"top\">".$lang['base']['bug_solution']."</td>";
						echo "<td>".urldecode($line->solution)."</td>";
					echo "</tr>";
				echo "</table>";
			echo "</td>";
			echo "</tr>";

		}
		echo "</table>";
	/*		[name] => Keine Planetenansicht
            [autor] => wodka
            [aToolV] => 2.5
            [date_in] => 123798777
            [date_out] => SimpleXMLElement Object
                (
                )

            [beschreibung] => Es wird kein Planet angezeigt
            [solution] => Upladet auf Version 2.5
	*/
	}else
		echo $lang['base']['bug_none'];
}else
	echo $lang['base']['bug'];
?>

